import { useEffect, useState } from "react"
import styled from "styled-components"

import { useStorage } from "@plasmohq/storage/hook"

import "@/style.css"

import { sendToBackground } from "@plasmohq/messaging"

const Container = styled.div`
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 200px;
  height: 100px;
`

const ButtonContainer = styled.div`
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
`

const Button = styled.button`
  width: 50px;
  height: 20px;
  background-color: #000000;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  color: #ffffff;
`

function IndexPopup() {
  // const [data, setData] = useState(0)
  const [test, setTest] = useStorage("test", (v) => (v === undefined ? 0 : v))

  useEffect(() => {
    console.log(process.env.NODE_ENV)
  }, [])

  return (
    <Container>
      <h1 className="text-blue-400 text-xs">{process.env.PLASMO_PUBLIC_API_URL}</h1>
      <h1 className="text-red-500 text-2xl">{test}</h1>
      <ButtonContainer>
        <Button onClick={() => setTest(test + 1)}>+</Button>
        <Button onClick={() => setTest(test - 1)}>-</Button>
      </ButtonContainer>
    </Container>
  )
}

export default IndexPopup
